<?php
declare (strict_types = 1);

namespace app\validate;

use think\Validate;

class User extends Validate
{
    protected $rule = [
        'name' => 'require|max:8|unique:users',
        'email' => 'email|unique:users',
        'password' => 'require|confirm|max:25|min:8|isnumber',
    ];

    protected $message = [
        'name.require' => '名称不能为空',
        'name.max' => '名称最多不能超过8个字符',
        'name.unique' => '名称以存在',
        'email' => '邮箱格式错误',
        'email.unique' => '邮箱以存在',
        'password.require' => '密码不能为空',
        'password.confirm' => '两次密码不同',
        'password.max' => '密码最多不能超过25个字符',
        'password.min' => '密码最少不能少于8个字符',
    ];

    protected function isnumber($value){
        return is_numeric($value) ? '密码不能为纯数字' : true;
    }
}
